The Greedy Gray Code Algorithm
نویسنده
چکیده
We reinterpret classic Gray codes for binary strings, permutations, combinations, binary trees, and set partitions using a simple greedy algorithm. The algorithm begins with an initial object and an ordered list of operations, and then repeatedly creates a new object by applying the first possible operation to the most recently created object.
منابع مشابه
Optimal Gray-code labeling and recognition algorithms for hypercubes
We present an optimal greedy algorithm which returns a Gray-code labeling of the nodes of an n-dimensional hypercube; that is, a labeling of the nodes with binary strings of length n for which the Hamming distance between two nodes is 1 if and only if these are adjacent in the hypercube. The proposed algorithm is very simple; it uses breadth-®rst search to guide the greedy choice of nodes and c...
متن کاملGreedy Pancake Flipping
We prove that a stack of pancakes can be rearranged in all possible ways by a greedy process: Flip the maximum number of topmost pancakes that gives a new stack. We also show that the previous Gray code for rearranging pancakes (S. Zaks, A New Algorithm for Generation of Permutations BIT 24 (1984), 196-204) is a greedy process: Flip the minimum number of topmost pancakes that gives a new stack.
متن کاملIndependent Even Cycles in the Pancake Graph and Greedy Prefix-Reversal Gray Codes
Any `–cycle, 6 6 `6 n!, can be embedded in the Pancake graph Pn, n > 3. In this paper we prove the existence of a family of maximal sets of even independent cycles with length bounded by O(n2). We introduce the new concept of Prefix– reversal Gray codes based on the independent cycles which extends the known greedy Prefix–reversal Gray code constructions considered by Zaks and Williams. We deri...
متن کاملUse of gray wolf algorithm to optimize gas microturbineUse of gray wolf algorithm to optimize gas microturbine
In this research, optimization of gas microturbine through economic, exergy and environmental analysis has been investigated by the gray wolf algorithm. First, a thermodynamic modeling was performed for each of the above modes, and then using the gray wolf method, optimum points were determined for each systemchr('39')s performance. For modeling, the code written in MATLAB software was used. ...
متن کاملGreedy flipping of pancakes and burnt pancakes
We prove that a stack of n pancakes is rearranged in all n! ways by repeatedly applying the following rule: Flip the maximum number of pancakes that gives a new stack. This complements the previously known pancake flipping Gray code (S. Zaks, A New Algorithm for Generation of Permutations BIT 24 (1984), 196–204) which we also describe as a greedy algorithm: Flip the minimum number of pancakes t...
متن کامل